Ext.define('appfe.stockor.exec.form.ExecHoldMonitorEditForm', {
    extend: 'Ext.form.Panel',
    alias: 'widget.stockor.exec.form.ExecHoldMonitorEditForm',
    requires: [
        'appfe.stockor.exec.form.ExecHoldMonitorEditFormController'
    ],
    controller: 'stockor.exec.form.ExecHoldMonitorEditForm',
    viewModel: {
        type: 'stockor.exec.ExecHold',//继承这个model, 同时下面有自己的个性化的定义
        data: {
            submitButtonText: '', //提交按钮文本
            actionType: 'insert', //insert. update.delete
            parentItemId: '',
            isValidSlimsymbol: false,
            // 表单信息
            holdStock: {
                slimsymbol: '',
                stkName: '',
                holdVolume: '',
                unitCost: '',
                monitorSelloutBarriePrice: '',
                monitorSelloutExecPrice: '',
                monitorSelloutExecVolume: ''
            }
        },
        formulas: {
            monitorSelloutExecProfit: function (get) {
                var monitorSelloutExecProfit = (get('holdStock.monitorSelloutExecPrice') - get('holdStock.unitCost')) * get('holdStock.monitorSelloutExecVolume');
                return '<span style="font-size: 26px;font-weight:bold">' + Ext.util.Format.number(monitorSelloutExecProfit, '￥0.00') + '</span>';
            }
        }
    },
    ui: 'won-form',
    autoScroll: true,
    buttonAlign: 'center',
    bodyPadding: 10,
    fieldDefaults: {
        labelAlign: 'right',
        labelWidth: 90
    },
    defaults: {
        // width: 600,
        labelWidth: 100,
        labelAlign: 'right',
        anchor: '100%',
        resizable: false,
        grow: true,
        allowBlank: false
    },
    items: [
        { xtype: 'hidden', name: 'slimsymbol', bind: '{holdStock.slimsymbol}' },
        {
            xtype: 'fieldcontainer',
            //fieldLabel: 'Availability',
            combineErrors: true,
            msgTarget: 'side',
            layout: 'hbox',
            defaults: {
                flex: 1,
                //labelAlign: 'top',
                hideLabel: false
            },
            items: [{
                xtype: 'displayfield',
                name: 'symbol',
                fieldLabel: '股票简码',
                bind: '{holdStock.slimsymbol}'
            }, {
                xtype: 'displayfield',
                name: 'name',
                fieldLabel: '股票名称',
                bind: '{holdStock.stkName}'
            }]
        }, {
            xtype: 'fieldcontainer',
            //fieldLabel: 'Availability',
            combineErrors: true,
            msgTarget: 'side',
            layout: 'hbox',
            defaults: {
                flex: 1
            },
            items: [{
                xtype: 'displayfield',
                fieldLabel: '持仓数量',
                name: 'holdVolume',
                bind: '{holdStock.holdVolume}'
            }, {
                xtype: 'displayfield',
                fieldLabel: '每股成本',
                name: 'unitCost',
                bind: '￥{holdStock.unitCost}'
            }]
        }, {
            xtype: 'fieldset',
            title: '智能监控价格自动卖出(招商证券)',
            defaultType: 'numberfield',
            defaults: {
                anchor: '100%',
                allowBlank: false,
                blankText: "不能为空，请填写"
            },
            items: [
                {
                    fieldLabel: '监控价(￥)',
                    afterLabelTextTpl: ['<span style="color:red;font-weight:bold" data-qtip="必填项">*</span>'],
                    name: 'monitorSelloutBarriePrice',
                    decimalPrecision: 2,//这里设置保留小数位数
                    bind: '{holdStock.monitorSelloutBarriePrice}'
                }, {
                    fieldLabel: '执行价(￥)',
                    afterLabelTextTpl: ['<span style="color:red;font-weight:bold" data-qtip="必填项">*</span>'],
                    name: 'monitorSelloutExecPrice',
                    decimalPrecision: 2,//这里设置保留小数位数
                    bind: '{holdStock.monitorSelloutExecPrice}'
                }, {
                    fieldLabel: '执行量',
                    afterLabelTextTpl: ['<span style="color:red;font-weight:bold" data-qtip="必填项">*</span>'],
                    name: 'monitorSelloutExecVolume',
                    allowDecimals: false,
                    bind: '{holdStock.monitorSelloutExecVolume}'
                }
            ]
        }, {
            xtype: 'displayfield',
            fieldLabel: '预计执行损益',
            name: 'monitorSelloutExecProfit',
            bind: '{monitorSelloutExecProfit}'
        }
    ],
    buttons: [
        { // 提交按钮
            xtype: 'buttongreen',
            formBind: true,
            handler: 'submitForm',
            iconCls: 'x-fa fa-plus white-fontawesome-icon',
            text: '提交'
        }
    ],
    listeners: {
        //afterrender: 'afterrender'
    }
});